import { createContext, useContext, useMemo, useReducer } from "react";


const reducer = (state, action) => {
    switch (action.type) {
        case '_aaa_change_':
            return {
                ...state,
                aaa: action.payload
            }
    }
}
const defaultValue = {
    aaa: ''
}
export const Context = createContext()

export const useInitGlobalValue = () => {
    const [state, dispatch] = useReducer(reducer, defaultValue);
    const initContextValue = useMemo(() => ({ state, dispatch }), [state, dispatch])
    return initContextValue;
}

export const useGlobalValue = () => {
    return useContext(Context);
}